package com.robustel.dispatching.application;

import com.robustel.dispatching.domain.elevator.Elevator;
import com.robustel.dispatching.domain.elevator.ElevatorRepository;
import org.springframework.stereotype.Service;

@Service
public class ResettingElevatorApplication {
    private final ElevatorRepository elevatorRepository;

    public ResettingElevatorApplication(ElevatorRepository elevatorRepository) {
        this.elevatorRepository = elevatorRepository;
    }

    public void doResetElevator(Long elevatorId) {
        var elevator = elevatorRepository.findById(elevatorId).orElseThrow(() -> new Elevator.ElevatorNotFoundException(elevatorId));
        elevator.reset();
        elevatorRepository.save(elevator);
    }
}
